package Sequence::Infinite::Filter;
use base 'Sequence::Infinite';

sub new {
    my( $class, $bool_filter_subref, $sequence ) = @_;
    my $this = $class->SUPER::new();
    
    $this->{sequence} = $sequence;
    $this->{filter} = $bool_filter_subref;
    
    $this;
}

sub increment {
    my( $this ) = @_;
    
    my $val = $_ = $this->{sequence}->increment;
    
    while( not $this->{filter}->() ) {
        $val = $_ = $this->{sequence}->increment
    }

    $val;
}

1;
